package cn.hejiang.user.conrtoller;

import cn.hejiang.basic.exception.BusinessException;
import cn.hejiang.basic.util.AjaxResult;
import cn.hejiang.user.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;

    @PostMapping("/smsCode")
    public AjaxResult smsCode(@RequestBody Map<String, String> param) {
        try {
            verifyCodeService.smsCode(param);
            return AjaxResult.me();
        } catch (BusinessException e) {
            e.printStackTrace();
            return new AjaxResult().me().setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return new AjaxResult().me().setMessage("系统繁忙，请稍后重试");
        }
    }
}
